package gold.digger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC223 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
            int area1 = (C - A) * (D - B);
            int area2 = (G - E) * (H - F);

            if (C <= E || F >= D || B >= H || A >= G) {
                return area1 + area2; //无重叠
            }

            int topX = Math.min(G, C), topY = Math.min(H, D);
            int bottomX = Math.max(E, A), bottomY = Math.max(B, F);
            return area1 - (topX - bottomX) * (topY - bottomY) + area2;
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC223 an = new LC223();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
